package main

import (
	. "fmt"
	"time"
)

//time.Now()  // 当前时间
//time.Now().Unix()  // 当前时间戳
//time.Now().UnixNano()  // 当前纳秒时间戳

func main() {
	//Println(time.Now())
	//Println(time.Now().Unix())
	wd := time.Now().Weekday()
	Println(wd)
	// 将时间戳转为时间
	timestamp := time.Now().Unix()
	resTime := time.Unix(timestamp, 0)  // 第一个参数为Unix秒时间，第二个参数为UnixNano纳秒时间
	Printf("%v --- %T\n", resTime, timestamp)
	t := resTime.Format("2006-01-02 15:04:05")
	Println(t)
	t1 := time.Now().Format("2006-01-02 15:04:05")
	Println("t1:", t1)
	t2 := time.Now().Format(time.ANSIC)
	t3 := time.Now().Format(time.RFC822)
	t4 := time.Now().Format(time.RFC822Z)
	t5 := time.Now().Format(time.RFC850)

	t6 := time.Now().Format(time.RFC1123Z)
	t7 := time.Now().Format(time.RFC1123)
	t8 := time.Now().Format(time.Kitchen)
	t9 := time.Now().Format(time.RFC3339)
	t10 := time.Now().Format(time.RFC3339Nano)
	t11 := time.Now().Format(time.Stamp)
	t12 := time.Now().Format(time.StampMicro)
	t13 := time.Now().Format(time.StampMilli)
	t14 := time.Now().Format(time.StampNano)
	t15 := time.Now().Format(time.UnixDate)
	Println(t2)
	Println(t3)
	Println(t4)
	Println(t5)
	Println(t6)
	Println(t7)
	Println(t8)
	Println(t9)
	Println(t10)
	Println(t11)
	Println(t12)
	Println(t13)
	Println(t14)
	Println(t15)

	Println("Year:", time.Now().Year())
	Println("YearDay:", time.Now().YearDay())
	Println("Month:", time.Now().Month())
	Println("Day:", time.Now().Day())
	Println("Hour:", time.Now().Hour())
	Println("Minute:", time.Now().Minute())
	Println("Second:", time.Now().Second())
	Println("Nanosecond:", time.Now().Nanosecond())
	Println("Unix:", time.Now().Unix())
	Println("UnixNano:", time.Now().UnixNano())
	Println(time.Now().Date())
	Println("Local:", time.Now().Local())
	Println(time.Now().Zone())
	Println("UTC:", time.Now().UTC())

	// 将时间转为时间戳
	timeLocal, _ := time.ParseInLocation("2006-01-02 15:04:05", t, time.Local)
	Println(timeLocal)
	Println(timeLocal.Unix())

}
